package javacafe.action.studybbs;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javacafe.action.Action;
import javacafe.action.ActionForward;
import javacafe.dto.member.LoginInfoDTO;
import javacafe.dto.studybbs.StudyBBSReplyDTO;
import javacafe.service.StudyBBSService;
import javacafe.serviceimple.StudyBBSServiceImpl;

public class UpdateReplyAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {

		int m_no = ((LoginInfoDTO)request.getSession().getAttribute("loginInfo")).getM_no();
		int sbr_no = Integer.parseInt(request.getParameter("sbr_no"));
		String sbr_content = request.getParameter("sbr_content");
		
		StudyBBSService studyBBSService = StudyBBSServiceImpl.getInstance();
		StudyBBSReplyDTO replyDTO = new StudyBBSReplyDTO();
		replyDTO.setM_no(m_no);
		replyDTO.setSbr_no(sbr_no);
		replyDTO.setSbr_content(sbr_content);
		
		System.out.println(replyDTO);
		
		studyBBSService.updateReply(replyDTO);
		
		ActionForward forward = new ActionForward();
		forward.setUrl("readstudypost");
				
		return forward;
	}

}
